﻿using LEDScreenLinkTool.Model;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace LEDScreenLinkTool.Util
{
    public class MessageBoxHelper
    {

        public static IPendingHandler PendingBox(object sender, string LoadingText)
        {
            DependencyObject dep = sender as DependencyObject;
            string content = LoadingText;
            return Panuon.WPF.UI.PendingBox.Show(Window.GetWindow(dep), content, "");
        }


        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="win"></param>
        /// <returns></returns>
        public static void InfoBox(object sender, EMessageCode infoCode = EMessageCode.Info)
        {
            string msg = ResourceHelper.GetString($"EMessageCode_{infoCode}");
            if (sender is DependencyObject dep)
            {
                _ = MessageBoxX.Show(Window.GetWindow(dep), msg, "Info", MessageBoxIcon.Info, DefaultButton.YesOK, 5);
                Window.GetWindow(dep)?.Activate();
            }
        }

        /// <summary>
        /// 成功
        /// </summary>
        /// <param name="win"></param>
        /// <returns></returns>
        public static void InfoBox(object sender, string msg)
        {
            if (sender is DependencyObject dep)
            {
                _ = MessageBoxX.Show(Window.GetWindow(dep), msg, "Info", MessageBoxIcon.Info, DefaultButton.YesOK);
                Window.GetWindow(dep)?.Activate();
            }
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="win"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static void WarningBox(object sender, string msg)
        {
            if (sender is DependencyObject dep)
            {
                _ = MessageBoxX.Show(Window.GetWindow(dep), msg, "Warning", MessageBoxIcon.Warning, DefaultButton.YesOK);
                Window.GetWindow(dep).Activate();
            }
        }

        /// <summary>
        /// 错误
        /// </summary>
        /// <param name="win"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static void WarningBox(object sender, EErrorCode errorCode = EErrorCode.Default)
        {
            string msg = ResourceHelper.GetString($"EErrorCode_{errorCode}");
            WarningBox(sender, msg);
        }
    }
}
